import 'package:flutter/material.dart';

class Widget_AbsorbPointer_Page extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("AbsorbPointer"),
        ),
        body: Center(
          child: Listener(
            child: AbsorbPointer(
                child: Listener(
                  child: Container(
                    width: 200,
                    height: 200,
                    color: Colors.orange,
                  ),
                  onPointerDown: (event) =>
                      debugPrint("内层点击事件"),
                  onPointerMove: (event) =>
                      debugPrint("onPointerMove:  " + event.delta.toString()),
                  onPointerUp: (event) =>
                      debugPrint("onPointerUp:  " + event.toString()),
                )
            ),
            onPointerDown: (event) =>debugPrint("外层点击事件"),
          ),
        ),
      ),
    );
  }
}

//按下打印-------外层点击事件

/**
 * 忽略触摸事件，
 * IgnorePointer和AbsorbPointer，这两个Widget都能阻止子树接收指针事件，不同的是AbsorbPointer本身是可以接收指针事件的(但其子树不行)，而IgnorePointer本身就不可以接收指针事件
 *   const AbsorbPointer({
    Key key,
    this.absorbing = true,
    Widget child,
    this.ignoringSemantics,
    })
 */
